package com.zcx.qshop.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.AsyType;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONObject;

/**
 * Created by Administrator on 2015/9/12 0012.
 */
@HttpInlet(Conn.INLET_JSON_ATTRIBUTE)
public class JsonAttributeAsyGet extends QSAsyGet<JsonAttributeAsyGet.Info> {

    public String gid, idone, idtwo;

    public JsonAttributeAsyGet(String gid, String idone, String idtwo, AsyCallBack<Info> asyCallBack) {

        super(asyCallBack);

        this.gid = gid;

        this.idone = idone;

        this.idtwo = idtwo;

        ASY_TYPE = AsyType.MAX_STALE;

    }

    @Override
    public Info parser(JSONObject object) {

        if(object.optString("message").equals("1")){

            Info info = new Info();

            info.price = object.optString("price");

            info.stock = object.optInt("stock");

            info.gaid = object.optString("gaid");

            return info;

        }

        return null;

    }

    public static class Info{

        public String price, gaid;

        public int stock;

    }

}
